package com.mavenq.fly.listener;

import com.mavenq.fly.business.entity.Person;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MsgEventListener {

    @EventListener(MsgEvent.class)
    public void msgEventListener(MsgEvent msgEvent){
        log.info(this.getClass().getSimpleName() + "监听到消息数据1：" + msgEvent.getSource());
        System.out.println("msgEvent:"+ msgEvent.getSource());
        if(msgEvent.getSource() instanceof Person){
            Person p = (Person)msgEvent.getSource();
            System.out.println("msgEvent转换Person:"+p);
        }
    }
}
